﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using QModels;
using QServices;
using QServices.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QControlCenter.ViewModel
{
	/// <summary>
	/// 配料单
	/// </summary>
	public partial class DosingScheduleViewModel : ObservableObject
	{

		[ObservableProperty]
		private string iD;

		[ObservableProperty]
		private string carId;

		[ObservableProperty]
		private string carNumber;

		[ObservableProperty]
		private int hourFirst;
		[ObservableProperty]
		private int hourSecond;
		[ObservableProperty]
		private int hourThird;
		[ObservableProperty]
		private int minuteFirst;
		[ObservableProperty]
		private int minuteSecond;
		[ObservableProperty]
		private int minuteThird;


		[ObservableProperty]
		private int first_80;
		[ObservableProperty]
		private int second_80;
		[ObservableProperty]
		private int third_80;
		[ObservableProperty]
		private int first_120;
		[ObservableProperty]
		private int second_120;
		[ObservableProperty]
		private int third_120;
		[ObservableProperty]
		private int first_160;
		[ObservableProperty]
		private int second_160;
		[ObservableProperty]
		private int third_160;
		[ObservableProperty]
		private int first_200;
		[ObservableProperty]
		private int second_200;
		[ObservableProperty]
		private int third_200;


		/// <summary>
		/// 电量
		/// </summary>
		[ObservableProperty]
		private decimal electricity;

		/// <summary>
		/// AGV状态
		/// </summary>
		[ObservableProperty]
		private string carStatus;


		/// <summary>
		/// 通信图路径
		/// </summary>
		[ObservableProperty]
		private string tongXinPath;

	

		public DosingScheduleViewModel()
		{

			var cars = AppRuntime.GetService().GetService<AgvCarService>().GetAgvCarList();
			if (cars != null && cars.Count > 0)
			{
				CarId = cars.FirstOrDefault().ID;
			}
			var info = AppRuntime.GetService().GetService<DosingScheduleService>().GetDosingScheduleByCarId(CarId);
			if (info != null)
			{
				ID = info.ID;
				HourFirst = info.HourFirst;
				HourSecond = info.HourSecond;
				HourThird = info.HourThird;

				MinuteFirst = info.MinuteFirst;
				MinuteSecond = info.MinuteSecond;
				MinuteThird = info.MinuteThird;

				First_80 = info.First_80;
				First_120 = info.First_120;
				First_160 = info.First_160;
				First_200 = info.First_200;

				Second_80 = info.Second_80;
				Second_120 = info.Second_120;
				Second_160 = info.Second_160;
				Second_200 = info.Second_200;

				Third_80 = info.Third_80;
				Third_120 = info.Third_120;
				Third_160 = info.Third_160;
				Third_200 = info.Third_200;


			}



		}







	}
}
